package com.zhouchao.web;

import java.io.IOException;
import java.sql.Connection;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zhouchao.bean.Dorm;
import com.zhouchao.dao.DormDao;
import com.zhouchao.util.DbUtil;

public class DormServlet extends HttpServlet {

	Connection con = null;
	DbUtil dbUtil = new DbUtil();
	DormDao  dormDao=new DormDao();
	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html");
		request.setCharacterEncoding("utf-8");
		//HttpSession session = request.getSession();
		//寝室id
		int dormBuildId = Integer.parseInt(request.getParameter("temp")) ;
		
		
		try {
			con=dbUtil.getCon();
			
		List<Dorm> dormList = dormDao.dormList(con, dormBuildId);
			
			request.setAttribute("dormList", dormList);
			request.setAttribute("mainPage", "dormManager/dorm.jsp");
			request.getRequestDispatcher("mainManager.jsp").forward(request, response);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
		
		
		
		
	
		
		
		
	}

	

}
